//
//  UIImage+Extension.h
//  JWBrowser
//
//  Created by Dejun Liu on 14-11-5.
//  Copyright (c) 2014年 JW. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Accelerate/Accelerate.h>
#import <QuartzCore/QuartzCore.h>

@interface UIImage (Extension)

// 从颜色获取一个指定尺寸的图片

+ (UIImage *)imageFromColor:(UIColor *)color size:(CGSize) size;

+ (UIImage *)imageTileName:(NSString *)name; // 平铺图片

+(UIImage*)imageFromView:(UIView *)theView; // 对一个view截图

- (NSData *)dataPNG;

- (NSData *)dataJPEGWithCompressionQuality:(float) cq;

- (CGSize)imageEquilibriumNeedSize:(CGSize)radioSize;

//resize
- (UIImage *)croppedImage:(CGRect)bounds;
- (UIImage *)thumbnailImage:(NSInteger)thumbnailSize
          transparentBorder:(NSUInteger)borderSize
               cornerRadius:(NSUInteger)cornerRadius
       interpolationQuality:(CGInterpolationQuality)quality;
- (UIImage *)resizedImage:(CGSize)newSize
     interpolationQuality:(CGInterpolationQuality)quality;
- (UIImage *)resizedImageWithContentMode:(UIViewContentMode)contentMode
                                  bounds:(CGSize)bounds
                    interpolationQuality:(CGInterpolationQuality)quality;
- (UIImage *)resizedImage:(CGSize)newSize
                transform:(CGAffineTransform)transform
           drawTransposed:(BOOL)transpose
     interpolationQuality:(CGInterpolationQuality)quality;
- (CGAffineTransform)transformForOrientation:(CGSize)newSize;

//圆角
- (UIImage *)roundedCornerImage:(NSInteger)cornerSize borderSize:(NSInteger)borderSize;
- (void)addRoundedRectToPath:(CGRect)rect context:(CGContextRef)context ovalWidth:(CGFloat)ovalWidth ovalHeight:(CGFloat)ovalHeight;

//alpha
- (BOOL)hasAlpha;
- (UIImage *)imageWithAlpha;
- (UIImage *)transparentBorderImage:(NSUInteger)borderSize;
- (CGImageRef)newBorderMask:(NSUInteger)borderSize size:(CGSize)size;

//滤镜
// 0.0 to 1.0
- (UIImage*)blurredImage:(CGFloat)blurAmount;

//从一种颜色添加图片
+ (UIImage *)imageWithColor:(UIColor *)color;

//截屏
+ (UIImage *)screenshot;

- (UIImage *)scaleToSize:(UIImage *)img size:(CGSize)size;


@end
